package com.ruoyi.jxxwx.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jxxwx.domain.JxxPlace;
import com.ruoyi.jxxwx.service.IJxxPlaceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 场所信息Controller
 * 
 * @author wh
 * @date 2025-04-10
 */
@RestController
@RequestMapping("/jxxwx/place")
public class JxxPlaceController extends BaseController
{
    @Autowired
    private IJxxPlaceService jxxPlaceService;

    /**
     * 查询场所信息列表
     */
    @PreAuthorize("@ss.hasPermi('jxxwx:place:list')")
    @GetMapping("/list")
    public TableDataInfo list(JxxPlace jxxPlace)
    {
        startPage();
        List<JxxPlace> list = jxxPlaceService.selectJxxPlaceList(jxxPlace);
        return getDataTable(list);
    }

    /**
     * 导出场所信息列表
     */
    @PreAuthorize("@ss.hasPermi('jxxwx:place:export')")
    @Log(title = "场所信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JxxPlace jxxPlace)
    {
        List<JxxPlace> list = jxxPlaceService.selectJxxPlaceList(jxxPlace);
        ExcelUtil<JxxPlace> util = new ExcelUtil<JxxPlace>(JxxPlace.class);
        util.exportExcel(response, list, "场所信息数据");
    }

    /**
     * 获取场所信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('jxxwx:place:query')")
    @GetMapping(value = "/{placeId}")
    public AjaxResult getInfo(@PathVariable("placeId") Long placeId)
    {
        return AjaxResult.success(jxxPlaceService.selectJxxPlaceByPlaceId(placeId));
    }

    /**
     * 新增场所信息
     */
    @PreAuthorize("@ss.hasPermi('jxxwx:place:add')")
    @Log(title = "场所信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JxxPlace jxxPlace)
    {
        //场所状态默认正常0
        jxxPlace.setPlaceStatus(0l);
        return toAjax(jxxPlaceService.insertJxxPlace(jxxPlace));
    }

    /**
     * 修改场所信息
     */
    @PreAuthorize("@ss.hasPermi('jxxwx:place:edit')")
    @Log(title = "场所信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JxxPlace jxxPlace)
    {
        return toAjax(jxxPlaceService.updateJxxPlace(jxxPlace));
    }

    /**
     * 删除场所信息
     */
    @PreAuthorize("@ss.hasPermi('jxxwx:place:remove')")
    @Log(title = "场所信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{placeIds}")
    public AjaxResult remove(@PathVariable Long[] placeIds)
    {
        return toAjax(jxxPlaceService.deleteJxxPlaceByPlaceIds(placeIds));
    }
}
